<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/28 0028
 * Time: 下午 2:41
 */

namespace app\sports_admin\model;


use think\Model;
use traits\model\SoftDelete;

class ConstitutionType extends Model
{
    use SoftDelete;
    protected $pk = 'id';

    protected $autoWriteTimestamp = true;

    protected $table = 'constitution_type';
    //获取字段属性
    public function getGradeIdAttr($value)
    {
        $info = explode(',',trim($value,','));
        $temStr = '';
        for ($i=0;$i<count($info);$i++){
            switch ($info[$i]){
                case 1 : $temStr .= '一年级,';break;
                case 2 : $temStr .= '二年级,';break;
                case 3 : $temStr .= '三年级,';break;
                case 4 : $temStr .= '四年级,';break;
                case 5 : $temStr .= '五年级,';break;
                case 6 : $temStr .= '六年级,';break;
                case 7 : $temStr .= '七年级,';break;
                case 8 : $temStr .= '八年级,';break;
                case 9 : $temStr .= '九年级,';break;
            }
        }
        return trim($temStr,',');
    }
    /**
     * 列表
     * @param array $info 分页，检索
     */
    public static function typeList($info)
    {
        $rows = self::order($info['sort'],$info['sortOrder'])->page($info['page'])->limit($info['rows'])->select();
        $count = self::count();
        return ['total'=>$count,'rows'=>$rows];
    }
}